package Admin

import (
	"FromNowOnPromote/博客系统/Tblog/controllers"
	"FromNowOnPromote/博客系统/Tblog/models"
	"FromNowOnPromote/博客系统/Tblog/models/Admin"
)

type GetTuiSongBlog struct {
	controllers.MainController
}

func (this *GetTuiSongBlog) Get() {
	db := models.ConnDb()
	defer db.Close()
	var data []Admin.TBlogTuiSong
	//只推送最近6条数据
	err := db.Raw("SELECT * FROM tblogtuisong order by id DESC limit 6;").Scan(&data).Error
	if err != nil {
		body := map[string]interface{}{"code": 300, "msg": "请求失败"}
		this.Data["json"] = body
		this.ServeJSON()
		return
	}
	body := map[string]interface{}{"code": 200, "data": data, "msg": "请求成功"}
	this.Data["json"] = body
	this.ServeJSON()
	return
}
